//
//  CLDoctorAttentionTC.m
//  CareLink
//
//  Created by apple on 16/8/21.
//  Copyright © 2016年 Seven Team. All rights reserved.
//


#import "DoctorSelectTableViewController.h"
#import "CLDoctorTableViewCell.h"
#import "CLNetworkManager.h"
#import "DoctorSelectModel.h"
#import "DoctorBasicViewController.h"
#import "CLDoctorAttentionTC.h"
#import "CLDoctorAttentionModel.h"
#import "CLDoctorAttentionTableViewCell.h"
#import "CLSubmitDataVC.h"
#import "CLConsultDoctor.h"
static NSString *cellid = @"cellid";
@interface CLDoctorAttentionTC ()


/**
 *  医生数据
 */
@property (nonatomic,strong) NSArray *DoctorData;

@end

@implementation CLDoctorAttentionTC

- (void)viewDidLoad {
    [super viewDidLoad];
    // 预估行高
    self.tableView.estimatedRowHeight = 100;
    // 自动计算
    self.tableView.rowHeight = UITableViewAutomaticDimension;
    // 取消分割线
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    // 加载网络数据
    [self attentionMatchDoctors];
    //    // 设置数据源
    [self.tableView registerNib:[UINib nibWithNibName:@"CLDoctorAttentionTableViewCell" bundle:nil] forCellReuseIdentifier:cellid];
#warning mark ---------设置返回按钮文字为空
    // 设置返回的按钮的文字为空
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
}
// 匹配医生
- (void)attentionMatchDoctors {
    
    NSString *url = [[NSBundle mainBundle]pathForResource:@"DoctorSelect.json" ofType:nil];
    NSData *data = [NSData dataWithContentsOfFile:url];
    NSDictionary *response = [NSJSONSerialization JSONObjectWithData:data options:0 error:NULL];
    
    NSArray *DoctorData = [NSArray yy_modelArrayWithClass:[NSClassFromString(@"DoctorSelectModel") class] json:response[@"data"]];
    //    NSLog(@"%@",DoctorData);
    self.DoctorData = DoctorData;
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return self.DoctorData.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    CLDoctorAttentionTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellid forIndexPath:indexPath];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
#warning 艹艹艹往这里瞅！！！！！！！
    // block回调cell按钮的点击事件
    [cell setBlock:^(CLDoctorAttentionTableViewCell *cell, UIButton *btn) {
        CLConsultDoctor *consultDoctor = [[CLConsultDoctor alloc]init];
        [self.navigationController pushViewController:consultDoctor animated:YES];
        NSLog(@"-------------");
    }];
    cell.model = self.DoctorData[indexPath.row];
    return cell;
}

@end
